import MySQLdb, random

if __name__ == '__main__':
   db = MySQLdb.connect('39.106.2.56', 'root', 'sa0230**', 'wenda', charset='utf8')
   try:
      cursor = db.cursor()
      sql = 'insert into question(title, content, user_id, created_date, comment_count) values ("xxx","xxx",1,now(),0)'
      cursor.execute(sql)
      qid = cursor.lastrowid
      db.commit()
      print qid
   except Exception, e:
      print e
      db.rollback()
   db.close()
